package com.ce.webframework.sec.util;

import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.GrantedAuthorityImpl;
import org.acegisecurity.userdetails.User;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
//import com.ce.webframework.sec.service.ISecUserinfoService;
import com.ce.webframework.sec.vo.ResUserVO;
import com.ce.webframework.sec.vo.SecUserinfoVO;

/**
 * 安全相关操作
 *
 */
public class Security implements UserDetailsService {

	//private IUserService userService;
	//private ISecUserinfoService secUserinfoService;

	/**
	 * 继承于UserDetailsService的方法，用于加载用户的详细信息。
	 */
	public UserDetails loadUserByUsername(String username) {

		System.out.println("securite username:" + username);

		String[] usernameArray = username.split("-");

		String userCode = usernameArray[0];
		String password = usernameArray[1];

	//	SecUserinfoVO vo = secUserinfoService.getSecUser(userCode, password);
//		if (vo != null) {
//			System.out.println("security checkuser true");
//			GrantedAuthority[] auth = { new GrantedAuthorityImpl("ROLE_NORMAL") };
//			System.out.println("SecUserinfoVO--->"+vo);
//
//			return new ResUserVO(vo, true, true, true,
//					true, auth);
//		}
//

		return null;


	}

	/**
	 * 得到用户Service
	 * @return
	 */
//	public ISecUserinfoService getSecUserinfoService() {
//		return secUserinfoService;
//	}
//
//	/**
//	 * 设置用户Service
//	 * @param userService
//	 */
//	public void setSecUserinfoService(ISecUserinfoService secUserinfoService) {
//		this.secUserinfoService = secUserinfoService;
//	}
}

